import java.util.Arrays;
import java.util.Random;

public  class AVector implements Comparable<AVector> {
	
	private double x1;
	private double x2;
	private double y1;
	private double y2;
	private int l1;
	
	public AVector(int x1, int x2, int y1, int y2)
	{
		this.x1 = x1;
		this.x2 = x2;
		this.y1 = y1;
		this.y2 = y2;
		this.l1 = Math.abs(x1-x2) + Math.abs(y1-y2);
		
	}
	
	public int compareTo(AVector arg0){
		return this.l1 - arg0.l1;
	}
	
	public static void main (String[] args)  
    { 
		int nVector = 2000;
		Random rand = new Random();
		AVector[] array = new AVector[nVector];
		
		for(int i = 0; i < nVector; i ++)
		{
			int x1 = rand.nextInt(2000);
			int x2 = rand.nextInt(2000);
			int y1 = rand.nextInt(2000);
			int y2 = rand.nextInt(2000);
			
			AVector v = new AVector(x1, x2, y1, y2);
			array[i] = v;
		}
		
		System.out.println("Desordenado");
		
		for(int i = 0; i < nVector; i++)
		{
			System.out.println("L1 = " + array[i].l1);
		}
		
		Arrays.sort(array);
		System.out.println();
		System.out.println("Ordenado");
		
		for(int i = 0; i < nVector; i++)
		{
			System.out.println("L1 = " + array[i].l1);
		}
		
    }
	
}
